<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>幼儿照护</title>
  <link rel="stylesheet" href="/css/selectpage.css" type="text/css">
  <link rel="stylesheet" href="/js/layui-v2.6.6/layui/css/layui.css">
  <style>

    .recover{
      width: 7.5rem;
      height: 1rem;
      line-height: 1rem;
      font-size: .3rem;
      text-align: center;
      font-weight: 400;
      border-bottom: 1px solid #E0E0E0;
    }

    .popupIbox{
      margin-top: 15px;
      width: 90%;
    }

    .query{
      margin: 0 auto;display: block;
    }

  </style>
</head>
<body>

<header class="recover">幼儿照护</header>

<div class="complete"></div>
<div class="fixed-table-toolbar popupIbox">

  <div class="layui-form-item">
    <label class="layui-form-label">考生姓名:</label>
    <div class="layui-input-block">
      <input type="text" id="searchName" placeholder="请输入考生姓名" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">认证批次:</label>
    <div class="layui-input-block">
      <input type="text" id="cbatchName" placeholder="请输入认证批次名称" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">选择状态:</label>
    <div class="layui-input-block">
      <input name="" placeholder="请选择状态" class="layui-input" id="state">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">选择类型:</label>
    <div class="layui-input-block">
      <input name="" placeholder="请选择类型" class="layui-input" id="type">
    </div>
  </div>

  <div class="layui-form-item">
    <button class="layui-btn layui-btn-normal query" onclick="reLoad()">查询</button>
  </div>

</div>

<div id="exampleTable" lay-filte="Event"></div>

<script src="/js/jquery.min.js?v=2.1.4"></script>
<script type="text/javascript" src="/js/selectpage.js" ></script>
<script src="/js/layui-v2.6.6/layui/layui.js"></script>
<script>
  document.documentElement.style.fontSize = (document.querySelector("body").clientWidth / 750) * 100 +'px';
  let state = '',type = '', prefix = "/jzweb/stuSignUp", pages = 1;

  $.ajax({
    url : "/jzApi/certificates/selBatchList",
    type:'get',
    data:{
      type:1,
      name:'',
      all:'1'
    },
    success : function(r) {
      //考生
      $('#cbatchName').selectPage({
        showField: 'certificateName',
        keyField: 'id',
        data: r.data,
        pageSize:20,
        focusDropList:false,
        //向服务端提交的参数中，增加已选中的
        //设置返回-1，意为通知服务端返回空列表，初始化时使用
        params: function(){
          var pv = $('#cbatchName').val();
          return {'cbatchId': pv?pv:''};
        },
        //格式化显示项目，提供源数据进行使用
        formatItem : function(data){
          return data.certificateName;
        },
        eAjaxSuccess : function(d){
          var result;
          if(d) result = d.data;
          else result = undefined;
          return result;
        }
      });
    }
  });

  function reLoad() {
    layui.use('table', function (res) {
      let table = layui.table;
      table.reload('idTest', {
        url: prefix + "/list",
        where:{
          name: $("#searchName").val() ,
          state: state,
          orgId: '',
          cbatchName: $("#cbatchName").val() ,
          type: type
        }
      });
    })
    // $(".complete").hide();
    // $(".popupIbox").hide();
  }

  layui.use(['dropdown','table'], function(){
    let dropdown = layui.dropdown,
            table = layui.table;

    dropdown.render({
      elem: '#state'
      ,data: [
        {
          title: '请选择状态'
          ,id: -1
        },{
          title: '待审核'
          ,id: 0
        },{
          title: '待缴费'
          ,id: 1
        },{
          title: '未通过'
          ,id: 2
        },{
          title: '已分配'
          ,id: 3
        },{
          title: '已缴费'
          ,id: 4
        },{
          title: '待分配'
          ,id: 5
        },{
          title: '已过理论'
          ,id: 6
        },{
          title: '已出证书'
          ,id: 7
        },{
          title: '考试中'
          ,id: 8
        },{
          title: '已删除'
          ,id: 9
        },{
          title: '已交卷'
          ,id: 10
        }]
      ,click: function(obj){
        this.elem.val(obj.title);
        if( obj.id == -1 ){
          state = '';
        }else{
          state = obj.id;
        }
      }
    });
    dropdown.render({
      elem: '#type'
      ,data: [
        {
          title: '请选择类型'
          ,id: -1
        },{
          title: '在校考生'
          ,id: 0
        },{
          title: '社会考生'
          ,id: 1
        }]
      ,click: function(obj){
        this.elem.val(obj.title);
        if( obj.id == -1 ){
          type = '';
        }else{
          type = obj.id;
        }
      }
    });

    table.render({
      elem: '#exampleTable'
      , url: prefix + "/list" //数据接口
      , cellMinWidth: 100 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
      , page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
        layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
        , curr: pages //设定初始在第 5 页
        , groups: 3 //只显示 1 个连续页码
        , limit : 20
      },
      where:{
        name:$("#searchName").val(),
        state:$("#state").val(),
        orgId:'',
        cbatchName:$("#cbatchName").val(),
        type:$("#type").val()
      }
      ,loading:true
      , id: 'idTest'
      , cols: [[
        {field: 'id', type: 'checkbox'},
        {
          field: 'cbatchName',
          title: '考试批次名称',
          width: 400
        },
        {
          field: 'orgName',
          title: '考点名称',
          width: 150
        },
        {
          field: 'name',
          title: '考生姓名',
        },
        {
          field: 'ticketNumber',
          title: '考号',
          width: 200
        },
        {
          field: 'type',
          title: '考生类型',
          templet:function(d) {
            if (d.type == 0){
              return "在校考生"
            }else if (d.type == 1) {
              return  "社会考生"
            }
          }
        },
        {
          field: 'idNumber',
          title: '考生编号',
          width: 200
        },
        {
          field: 'eallocationNum',
          title: '考场名称',
        },
        {
          field: 'signUpTime',
          title: '报名时间',
          templet:function (d) {
            if(d.signUpTime !='' && d.signUpTime !=null){
              return d.signUpTime.substring(0,10)
            }else{
              return d.signUpTime
            }
          },
          width: 120
        },
        {
          field: 'state',
          title: '审核状态',
          width: 100,
          templet:function (d) { //（0待审核，1待缴费，2未通过，3已分配，4已缴费，5待分配，6已过理论，7已出证书，8考试中，9已删除，10已交卷）
            if (d.state == 0) {
              return '<span class="label label-primary">待审核</span>';
            } else if (d.state == 1) {
              return '<span class="label label-success">待缴费</span>';
            } else if (d.state == 2) {
              return '<span class="label label-danger">未通过</span>';
            } else if (d.state == 3) {
              return '<span class="label label-white">已分配</span>';
            } else if (d.state == 4) {
              return '<span class="label label-info">已缴费</span>';
            } else if (d.state == 5) {
              return '<span class="label label-important">待分配</span>';
            } else if (d.state == 6) {
              return '<span class="label label-inverse">已过理论</span>';
            } else if (d.state == 7) {
              return '<span class="label label-warning-light">已出证书</span>';
            } else if (d.state == 8) {
              return '<span class="label label-danger">考试中</span>';
            } else if (d.state == 9) {
              return '<span class="label label-default">已删除</span>';
            } else if (d.state == 10) {
              return '<span class="label label-inverse">已交卷</span>';
            }
          }
        },
        {
          field: 'checkerName',
          title: '审核人',
          width: 80
        },
        , {field: 'id', title: '操作', width:150
          ,templet:function (d){
            var s = `<a class="layui-btn layui-btn-sm layui-btn-danger" href="#" title="删除"  mce_href="#" onclick="remove('${d.id}')">删除</a>`;
            var g = `<a class="layui-btn layui-btn-sm" href="#" title="重考"  mce_href="#" onclick="reExam('${d.id}')">重考</a>`;
            return s + g;
          }
        }
      ]],
      jump: function (obj, first) {
        //首次不执行
        if (!first) {
          pages = obj.curr
        }
      }
      , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
        return {
          "code": res.code, //解析接口状态
          "count": res.data.total,
          "data": res.data.records //解析数据列表
        };
      }
      , done: function () {
        $(".layui-table-main tr").each(function (index, val) {
          $(".layui-table-fixed").each(function () {
            $($(this).find(".layui-table-body tbody tr")[index]).height($(val).height());
          });
        });
        $(".layui-table-header tr").each(function (index, val) {
          $(".layui-table-fixed").each(function () {
            $($(this).find(".layui-table-header thead tr")[index]).height($(val).height());
          });
        });

      }
    });

  })

  //删除
  function remove(id) {
    layer.confirm('确定要删除选中的记录？', {
      btn: ['确定', '取消']
    }, function () {
      $.ajax({
        url: prefix + "/remove",
        type: "post",
        data: {
          'id': id
        },
        success: function (r) {
          if (r.code == 0) {
            layer.msg(r.msg);
            reLoad();
          } else {
            layer.msg(r.msg);
          }
        }
      });
    })
  }

  //重考
  function reExam(id) {
    layer.confirm('确定让该考生重考吗', {
      btn: ['确定', '取消']
    }, function () {
      $.ajax({
        url: prefix + "/reExam",
        type: "post",
        data: {
          'id': id
        },
        success: function (r) {
          if (r.code == 0) {
            layer.msg(r.msg);
            reLoad();
          } else {
            layer.msg(r.msg);
          }
        }
      });
    })
  }

  // $(".demand").click(function (){
  //     $(".popupAlt").css('width','600px').show();
  //     $(".complete").show();
  // })
  //
  //
  // $(".closeImg").click(function (){
  //     $(".popupAlt").hide();
  //     $(".popupIbox").hide();
  //     $(".complete").hide();
  // })
  //
  //
  // $(".arrange").click(function (){
  //     $(".complete").show();
  //     $(".popupIbox").show();
  // })


</script>

</body>
</html>